package com.dingreading.cloud.admin.service.impl;

import com.dingreading.cloud.admin.entity.CorporationContractFile;
import com.dingreading.cloud.admin.entity.table.CorporationContractFileTableDef;
import com.dingreading.cloud.admin.mapper.CorporationContractFileMapper;
import com.dingreading.cloud.admin.service.CorporationContractFileService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 服务层实现。
 *
 * @author Administrator
 * @since 2024-11-16
 */
@Service
public class CorporationContractFileServiceImpl extends BaseServiceImpl<CorporationContractFileMapper, CorporationContractFile, CorporationContractFileTableDef> implements CorporationContractFileService {

    @Override
    protected CorporationContractFileTableDef getTable() {
        return CorporationContractFileTableDef.corporationContractFile;
    }

    @Override
    public List<CorporationContractFile> listByContractId(Long contractId) {
        return getMapper().selectListByCondition(table.contractId.eq(contractId));
    }

    @Override
    public void deleteByFileIdsNotIn(Long contractId, List<Long> fileIds) {
        getMapper().deleteByCondition(table.contractId.eq(contractId).and(table.id.notIn(fileIds)));
    }

    @Override
    public int deleteByContractId(Long contractId) {
        return getMapper().deleteByCondition(table.contractId.eq(contractId));
    }

    @Override
    public List<CorporationContractFile> listByContractIdIn(List<Long> contractIds) {
        return getMapper().selectListByCondition(table.contractId.in(contractIds));
    }
}
